package com.zhongke.DKYCboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhongke.DKYCboot.bean.BaseRole;
import com.zhongke.DKYCboot.mapper.BaseRoleMapper;
import com.zhongke.DKYCboot.service.BaseRoleService;
import com.zhongke.DKYCboot.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseRoleServiceImpl implements BaseRoleService {
    @Autowired
    private BaseRoleMapper baseRoleMapper;



    /**
     * 查询(有参数是模糊查询，没有参数查询所有)
     * @param baseRole
     * @return
     */
    @Override
    public Msg selectBaseRoleByRoleName(BaseRole baseRole) {
        Integer pageNum = baseRole.getPageNum();
        Integer pageSize= baseRole.getPageSize();
        PageHelper.startPage(pageNum,pageSize);
        String roleName=baseRole.getRole_Name();
        List<BaseRole> list = baseRoleMapper.selectBaseRoleByRoleName(roleName);
        if(list!=null ){
            PageInfo<BaseRole> BaseRolePageInfo = new PageInfo<>(list);
            return Msg.success(BaseRolePageInfo);
        }else{
            return Msg.fail("失败");
        }

    }



    /**
     * 增加
     * @param baseRole
     * @return
     */
    @Override
    public Msg insertBaseRole(BaseRole baseRole) {
        int aaa = baseRoleMapper.insertBaseRole(baseRole);
        return Msg.success(aaa);
    }

    /**
     * 修改
     * @param baseRole
     * @return
     */
    @Override
    public Msg updateBaseRole(BaseRole baseRole) {
        int aaa=baseRoleMapper.updateBaseRole(baseRole);
        return Msg.success(aaa);
    }

    /**
     * 删除
     * @param baseRole
     * @return
     */
    @Override
    public Msg deleteBaseRole(BaseRole baseRole) {
        int aaa=baseRoleMapper.deleteBaseRole(baseRole);
        return Msg.success(aaa);
    }

}
